//
//  AddPersonView.m
//  SoundPill
//
//  Created by 宋旭东 on 15/3/13.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "AddPersonView.h"

@implementation AddPersonView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}
- (void)createSubViews
{
    UIView *searchBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 40)];
    searchBar.backgroundColor = [UIColor colorWithRed:0.749f green:0.749f blue:0.757f alpha:1.00f];
    [self addSubview:searchBar];
    
    UITextField *searchField = [[UITextField alloc] initWithFrame:CGRectMake(10, 5, self.frame.size.width - 10 -40, 30)];
    searchField.placeholder = @"这是谁？圈出他（她）吧";
    searchField.delegate = self;
    [searchField setClearButtonMode:UITextFieldViewModeWhileEditing];
    [self addSubview:searchField];
    
    UIButton *cancel = [UIButton buttonWithType:UIButtonTypeCustom];
    cancel.frame = CGRectMake(self.frame.size.width - 40, 0, 40, 40);
    [cancel setTitle:@"X" forState:UIControlStateNormal];
    [cancel addTarget:self action:@selector(SearchCancel:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:cancel];
    
    self.personList = [[UITableView alloc] initWithFrame:CGRectMake(0, searchBar.frame.size.height, self.frame.size.width, self.frame.size.height - searchBar.frame.size.height)];
    _personList.delegate = self;
    _personList.dataSource = self;
    [_personList registerClass:[UITableViewCell class] forCellReuseIdentifier:@"person"];
    [self addSubview:_personList];
}

- (void)SearchCancel:(UIButton *)sender
{
    
}
#pragma mark tableview协议
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"person"];
    return cell;
}
#pragma mark textfield 协议
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    return YES;
}
- (BOOL)textFieldShouldClear:(UITextField *)textField{
    return YES;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
